home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_apache2.idb / usr / freeware / apache2 / include / apr_md4.h.z / apr_md4.h
C/C++ Source or Header  |  2002-07-08  |  6KB  |  172 lines

  1. /* ====================================================================
  2.  * The Apache Software License, Version 1.1
  3.  *
  4.  * Copyright (c) 2001-2002 The Apache Software Foundation.  All rights
  5.  * reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  *
  11.  * 1. Redistributions of source code must retain the above copyright
  12.  *    notice, this list of conditions and the following disclaimer.
  13.  *
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in
  16.  *    the documentation and/or other materials provided with the
  17.  *    distribution.
  18.  *
  19.  * 3. The end-user documentation included with the redistribution,
  20.  *    if any, must include the following acknowledgment:
  21.  *       "This product includes software developed by the
  22.  *        Apache Software Foundation (http://www.apache.org/)."
  23.  *    Alternately, this acknowledgment may appear in the software itself,
  24.  *    if and wherever such third-party acknowledgments normally appear.
  25.  *
  26.  * 4. The names "Apache" and "Apache Software Foundation" must
  27.  *    not be used to endorse or promote products derived from this
  28.  *    software without prior written permission. For written
  29.  *    permission, please contact apache@apache.org.
  30.  *
  31.  * 5. Products derived from this software may not be called "Apache",
  32.  *    nor may "Apache" appear in their name, without prior written
  33.  *    permission of the Apache Software Foundation.
  34.  *
  35.  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  36.  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  37.  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  38.  * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
  39.  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  40.  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  41.  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  42.  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  43.  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  44.  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  45.  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  46.  * SUCH DAMAGE.
  47.  * ====================================================================
  48.  *
  49.  * This software consists of voluntary contributions made by many
  50.  * individuals on behalf of the Apache Software Foundation.  For more
  51.  * information on the Apache Software Foundation, please see
  52.  * <http://www.apache.org/>.
  53.  *
  54.  * This is derived from material copyright RSA Data Security, Inc.
  55.  * Their notice is reproduced below in its entirety.
  56.  *
  57.  * Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
  58.  * rights reserved.
  59.  *
  60.  * License to copy and use this software is granted provided that it
  61.  * is identified as the "RSA Data Security, Inc. MD4 Message-Digest
  62.  * Algorithm" in all material mentioning or referencing this software
  63.  * or this function.
  64.  *
  65.  * License is also granted to make and use derivative works provided
  66.  * that such works are identified as "derived from the RSA Data
  67.  * Security, Inc. MD4 Message-Digest Algorithm" in all material
  68.  * mentioning or referencing the derived work.
  69.  *
  70.  * RSA Data Security, Inc. makes no representations concerning either
  71.  * the merchantability of this software or the suitability of this
  72.  * software for any particular purpose. It is provided "as is"
  73.  * without express or implied warranty of any kind.
  74.  *
  75.  * These notices must be retained in any copies of any part of this
  76.  * documentation and/or software.
  77.  */
  78.  
  79. #ifndef APR_MD4_H
  80. #define APR_MD4_H
  81.  
  82. #include "apu.h"
  83. #include "apr_xlate.h"
  84. /**
  85.  * @file apr_md4.h
  86.  * @brief APR-UTIL MD4 Library
  87.  */
  88. #ifdef __cplusplus
  89. extern "C" {
  90. #endif
  91.  
  92. /**
  93.  * @defgroup APR_Util_MD4 MD4 Library
  94.  * @ingroup APR_Util
  95.  * @{
  96.  */
  97.  
  98. #define APR_MD4_DIGESTSIZE 16
  99.  
  100. typedef struct apr_md4_ctx_t apr_md4_ctx_t;
  101.  
  102. /** MD4 context. */
  103. struct apr_md4_ctx_t {
  104.     /** state (ABCD) */
  105.     apr_uint32_t state[4];
  106.     /** number of bits, modulo 2^64 (lsb first) */
  107.     apr_uint32_t count[2];
  108.     /** input buffer */
  109.     unsigned char buffer[64];
  110. #if APR_HAS_XLATE
  111.     /** translation handle */
  112.     apr_xlate_t *xlate;
  113. #endif
  114. };
  115.  
  116. /**
  117.  * MD4 Initialize.  Begins an MD4 operation, writing a new context.
  118.  * @param context The MD4 context to initialize.
  119.  */
  120. APU_DECLARE(apr_status_t) apr_md4_init(apr_md4_ctx_t *context);
  121.  
  122. #if APR_HAS_XLATE
  123. /**
  124.  * MDr4 translation setup.  Provides the APR translation handle to be used 
  125.  * for translating the content before calculating the digest.
  126.  * @param context The MD4 content to set the translation for.
  127.  * @param xlate The translation handle to use for this MD4 context 
  128.  */
  129. APU_DECLARE(apr_status_t) apr_md4_set_xlate(apr_md4_ctx_t *context,
  130.                                             apr_xlate_t *xlate);
  131. #else
  132. #define apr_md4_set_xlate(context, xlate) APR_ENOTIMPL
  133. #endif
  134.  
  135. /**
  136.  * MD4 block update operation.  Continue an MD4 message-digest operation, 
  137.  * processing another message block, and updating the context.
  138.  * @param context The MD4 content to update.
  139.  * @param input next message block to update
  140.  * @param inputLen The length of the next message block
  141.  */
  142. APU_DECLARE(apr_status_t) apr_md4_update(apr_md4_ctx_t *context,
  143.                                          const unsigned char *input,
  144.                                          apr_size_t inputLen);
  145.  
  146. /**
  147.  * MD4 finalization.  Ends an MD4 message-digest operation, writing the 
  148.  * message digest and zeroing the context
  149.  * @param digest The final MD4 digest
  150.  * @param context The MD4 content we are finalizing.
  151.  */
  152. APU_DECLARE(apr_status_t) apr_md4_final(
  153.                                     unsigned char digest[APR_MD4_DIGESTSIZE],
  154.                                     apr_md4_ctx_t *context);
  155.  
  156. /**
  157.  * MD4 digest computation
  158.  * @param digest The MD4 digest
  159.  * @param input message block to use
  160.  * @param inputLen The length of the message block
  161.  */
  162. APU_DECLARE(apr_status_t) apr_md4(unsigned char digest[APR_MD4_DIGESTSIZE],
  163.                                   const unsigned char *input,
  164.                                   apr_size_t inputLen);
  165.  
  166. /** @} */
  167. #ifdef __cplusplus
  168. }
  169. #endif
  170.  
  171. #endif /* !APR_MD4_H */
  172.